<div style="font-size:12px;">
    This example demonstartes the new multi serach feature of jqGrid.<br>
    The search fields are in the toolbar. Click on search button  to toggle the search and enjoy
</div>
<br />
<table id="s1list" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="s1pager" class="scroll" style="text-align:center;"></div>
<script src="search1.js" type="text/javascript"> </script>
<br />
<div style="font-size:12px;">
<b> HTML </b>
<XMP>
...
<table id="s1list" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="s1pager" class="scroll" style="text-align:center;"></div>
<script src="search1.js" type="text/javascript"> </script>

</XMP>    
<b>Java Scrpt code</b>
<XMP>
...
jQuery("#s1list").jqGrid({
   	url:'search.php?q=1',
	datatype: "json",
   	colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
   	colModel:[
   		{name:'id',index:'id', width:65},
   		{name:'invdate',index:'invdate', width:90},
   		{name:'name',index:'name', width:100},
   		{name:'amount',index:'amount', width:80, align:"right"},
   		{name:'tax',index:'tax', width:80, align:"right", edittype:'select', editoptions:{value:":All;0.00:0.00;12:12.00;20:20.00;40:40.00;60:60.00;120:120.00"}},		
   		{name:'total',index:'total', width:80,align:"right"},		
   		{name:'note',index:'note', width:150, sortable:false}		
   	],
   	rowNum:10,
   	mtype: "POST",
   	rowList:[10,20,30],
   	imgpath: gridimgpath,
   	pager: jQuery('#s1pager'),
   	sortname: 'id',
    viewrecords: true,
	toolbar : [true,"top"],
    sortorder: "desc",
    caption:"Multiple Toolbar Search Example"
});
jQuery("#t_s1list").height(25).hide().filterGrid("s1list",{gridModel:true,gridToolbar:true});
jQuery("#sg_invdate").datepicker({dateFormat:"yy-mm-dd"});

jQuery("#s1list").navGrid('#s1pager',{edit:false,add:false,del:false,search:false,refresh:false})
.navButtonAdd("#s1pager",{caption:"Search",title:"Toggle Search",buttonimg:gridimgpath+'/find.gif',
	onClickButton:function(){ 
		if(jQuery("#t_s1list").css("display")=="none") {
			jQuery("#t_s1list").css("display","");
		} else {
			jQuery("#t_s1list").css("display","none");
		}
		
	} 
});
</XMP>
<b>PHP with MySQL</b>
<XMP>
...
$page = $_REQUEST['page']; // get the requested page
$limit = $_REQUEST['rows']; // get how many rows we want to have into the grid
$sidx = $_REQUEST['sidx']; // get index row - i.e. user click to sort
$sord = $_REQUEST['sord']; // get the direction
if(!$sidx) $sidx =1;

$wh = "";
$searchOn = Strip($_REQUEST['_search']);
if($searchOn=='true') {
	$sarr = Strip($_REQUEST);
	foreach( $sarr as $k=>$v) {
		switch ($k) {
			case 'id':
			case 'invdate':
			case 'name':
			case 'note':
				$wh .= " AND ".$k." LIKE '".$v."%'";
				break;
			case 'amount':
			case 'tax':
			case 'total':
				$wh .= " AND ".$k." = ".$v;
				break;
		}
	}
}
//echo $wh;
// connect to the database
$db = mysql_connect($dbhost, $dbuser, $dbpassword)
or die("Connection Error: " . mysql_error());

mysql_select_db($database) or die("Error conecting to db.");

switch ($examp) {
    case 1:
		$result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id".$wh);
		$row = mysql_fetch_array($result,MYSQL_ASSOC);
		$count = $row['count'];

		if( $count >0 ) {
			$total_pages = ceil($count/$limit);
		} else {
			$total_pages = 0;
		}
        if ($page > $total_pages) $page=$total_pages;
		$start = $limit*$page - $limit; // do not put $limit*($page - 1)
        if ($start<0) $start = 0;
        $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id".$wh." ORDER BY ".$sidx." ".$sord. " LIMIT ".$start." , ".$limit;
		$result = mysql_query( $SQL ) or die("Could not execute query.".mysql_error());
        $responce->page = $page;
        $responce->total = $total_pages;
        $responce->records = $count;
        $i=0;
		while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
			$responce->rows[$i]['id']=$row[id];
            $responce->rows[$i]['cell']=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]);
            $i++;
		} 
		echo $json->encode($responce); // coment if php 5
        //echo json_encode($responce);
           
        break;
    case 3:
}
mysql_close($db);
...
</XMP>
</div>